package com.employ.job.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.employ.common.annotation.Log;
import com.employ.common.core.controller.BaseController;
import com.employ.common.core.domain.AjaxResult;
import com.employ.common.enums.BusinessType;
import com.employ.job.domain.EmpResumes;
import com.employ.job.service.IEmpResumesService;
import com.employ.common.utils.poi.ExcelUtil;
import com.employ.common.core.page.TableDataInfo;

/**
 * 简历Controller
 *
 * @author ruoyi
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/job/resumes")
public class EmpResumesController extends BaseController
{
    @Autowired
    private IEmpResumesService empResumesService;

    /**
     * 查询简历列表
     */
    @PreAuthorize("@ss.hasPermi('job:resumes:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmpResumes empResumes)
    {
        startPage();
        List<EmpResumes> list = empResumesService.selectEmpResumesList(empResumes);
        return getDataTable(list);
    }

    /**
     * 导出简历列表
     */
    @PreAuthorize("@ss.hasPermi('job:resumes:export')")
    @Log(title = "简历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmpResumes empResumes)
    {
        List<EmpResumes> list = empResumesService.selectEmpResumesList(empResumes);
        ExcelUtil<EmpResumes> util = new ExcelUtil<EmpResumes>(EmpResumes.class);
        util.exportExcel(response, list, "简历数据");
    }

    /**
     * 获取简历详细信息
     */
    @PreAuthorize("@ss.hasPermi('job:resumes:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(empResumesService.selectEmpResumesById(id));
    }

    /**
     * 根据用户ID获取简历详细信息
     */
    @PreAuthorize("@ss.hasPermi('job:resumes:query')")
    @GetMapping(value = "/byUserId/{studentId}")
    public AjaxResult getInfoByUserId(@PathVariable("studentId") Long studentId)
    {
        List<EmpResumes> empResumesList = empResumesService.selectEmpResumesByUserId(studentId);
        return success(empResumesList);
    }

    /**
     * 新增简历
     */
    @PreAuthorize("@ss.hasPermi('job:resumes:add')")
    @Log(title = "简历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmpResumes empResumes)
    {
        return toAjax(empResumesService.insertEmpResumes(empResumes));
    }

    /**
     * 修改简历
     */
    @PreAuthorize("@ss.hasPermi('job:resumes:edit')")
    @Log(title = "简历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmpResumes empResumes)
    {
        return toAjax(empResumesService.updateEmpResumes(empResumes));
    }

    /**
     * 删除简历
     */
    @PreAuthorize("@ss.hasPermi('job:resumes:remove')")
    @Log(title = "简历", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(empResumesService.deleteEmpResumesByIds(ids));
    }
}
